<style>
    .layui-form-label {
        width: 100px;
    }
    .layui-input-block {
        margin-left: 130px;
    }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">订单编号：</label>
                                    <div class="layui-input-inline">
                                        <input name="code" class="layui-input" type="text" placeholder="请输入订单编号"/>
                                    </div>
                                </div>
                            </div>
                            <div class="query-rt">
                                <div class="layui-inline">
                                    <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog" lay-submit>查询</button>
                                    <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 表格 -->
            <table class="layui-table" id="storageCheckRepairResultOrderTable" lay-filter="storageCheckRepairResultOrderTable"></table>

        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="storageCheckRepairResultOrderTableTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
    <!--
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    -->
</script>

<script type="text/html" id="storageCheckRepairResultOrderTable4GenOrderTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">明细</a>
    <!--
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    -->
</script>

<script type="text/html" id="storageInventoryInoutTable4RepairOrderBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>

    <!--
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    -->
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="storageInventoryInoutForm">
    <form lay-filter="storageInventoryInoutForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <label class="layui-form-label" style="width: 90px">盘验任务信息</label>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label">盘验任务编号</label>
            <div class="layui-input-block">
                <input name="code" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">订单创建时间</label>
            <div class="layui-input-block">
                <input name="createTime" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">盘验员</label>
            <div class="layui-input-block">
                <input name="checkUserName" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">取货时间</label>
            <div class="layui-input-block">
                <input name="takeTime" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">盘验订单状态</label>
            <div class="layui-input-block">
                <input name="statusDesc" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <hr>
        <label class="layui-form-label" style="width: 70px">设备信息</label>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label">所属企业</label>
            <div class="layui-input-block">
                <input name="enterpriseName" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属车间</label>
            <div class="layui-input-block">
                <input name="workshopName" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">车间描述</label>
            <div class="layui-input-block">
                <input name="workshopDesc" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">所属柜子</label>
            <div class="layui-input-block">
                <input name="cabName" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">所属货位</label>
            <div class="layui-input-block">
                <input name="spaceCode" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>

        <hr>
        <label class="layui-form-label" style="width: 70px">物料信息</label>
        <hr>
        <table class="layui-table" id="storageInventoryInoutDetailTable" lay-filter="storageInventoryInoutDetailTable"></table>

    </form>
</script>

<script type="text/html" id="detailTable">

    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <div class="layui-form toolbar">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label w-auto">柜子编号：</label>
                            <div class="layui-input-inline mr0">
                                <input name="cabCode" class="layui-input" type="text" placeholder="请输入柜子编号"/>
                            </div>
                            <label class="layui-form-label w-auto">物料编号：</label>
                            <div class="layui-input-inline mr0">
                                <input name="skuCode" class="layui-input" type="text" placeholder="请输入物料编号"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn" lay-filter="formSubSearchLog" lay-submit><i class="layui-icon">&#xe615;</i>搜索</button>
                            <!--
                            <button id="storageInventoryInoutBtnAdd" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>
                            -->
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="storageInventoryInoutTable4RepairOrder" lay-filter="storageInventoryInoutTable4RepairOrder"></table>
            </div>
        </div>
    </div>
</script>


<script type="text/html" id="genOrderTable">

    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <!--
                <table class="layui-table" id="storageCheckRepairResultOrderTable4GenOrderInfo" lay-filter="storageCheckRepairResultOrderTable4GenOrderInfo"></table>
                <br>
                -->
                <!-- 表格 -->
                <table class="layui-table" id="storageCheckRepairResultOrderTable4GenOrder" lay-filter="storageCheckRepairResultOrderTable4GenOrder"></table>


            </div>
        </div>
    </div>
    <form lay-filter="genOrderForm" class="layui-form model-form">
        <div class="layui-form-item">
            <label class="layui-form-label">请选择供应商</label>
            <div class="layui-input-block">
                <select  name="supplierId" lay-filter="supplierId" lay-search lay-verify="required">
                    <option value=""> 请选择供应商</option>
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">物流联系人</label>
            <div class="layui-input-block">
                <input name="logisticsContact" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">收货联系人</label>
            <div class="layui-input-block">
                <input name="receiveContact" placeholder="" type="text" class="layui-input" lay-verify="" required/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">收货人电话</label>
            <div class="layui-input-block">
                <input name="phone" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">收货人地址</label>
            <div class="layui-input-block">
                <input name="addr" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">报修费用</label>
            <div class="layui-input-block">
                <input name="price" placeholder="" type="text" class="layui-input" lay-verify="required|decimal" required/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">物流单号</label>
            <div class="layui-input-block">
                <input name="expressNo" placeholder="" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>


        <div align="center" >
            <div class="layui-form-item text-right saveCancelBtn" >
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                <button class="layui-btn" lay-filter="storageInventoryInoutBtnGenOrderSubmit" lay-submit>提交</button>
            </div>
        </div>
        <br>
    </form>
</script>

<script type="text/html" id="detailResultTab">

    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <table class="layui-table" id="resultOrderTable" lay-filter="resultOrderTable"></table>
                <br>
                <!-- 表格 -->
                <table class="layui-table" id="detailResultTable" lay-filter="detailResultTable"></table>
            </div>
        </div>
    </div>

</script>

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;

        // 渲染表格
        var insTb = table.render({
            elem: '#storageCheckRepairResultOrderTable',
            url: config.base + 'enterprisecab/cabinet/admin/checkedRepairResultOrder/list',
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'checkbox'}

                ,{field: 'code', sort: true, title: '报修订单编号'}
                // ,{field: 'inType', sort: true, title: '存入方式',templet:function (d) {
                //         return '报废';
                //     }}
                ,{field: 'supplierName', sort: true, title: '供应商'}
                ,{field: 'logisticsContact', sort: true, title: '物流联系人'}
                ,{field: 'receiveContact', sort: true, title: '收货人'}
                ,{field: 'phone', sort: true, title: '收货人电话'}
                ,{field: 'addr', sort: true, title: '收货地址'}
                ,{field: 'quantity', sort: true, title: '报修数量'}
                ,{field: 'price', sort: true, title: '报修费用'}
                ,{field: 'statusDesc', sort: true, title: '回收状态'}
                ,{field: 'creatorName', sort: true, title: '创建人'}
                ,{field: 'createTime', sort: true, title: '创建时间'}
                // ,{field: 'isCheck', sort: true, title: '是否盘验',templet:function (d) {
                //         if(d.status=='checked'){
                //             return '是';
                //         }
                //         return  '否';
                //     }}



                // ,{field: 'no', sort: true, title: 'no'}
                // ,{field: 'day', sort: true, title: 'day'}
                // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                // ,{field: 'statusDesc', sort: true, title: '状态'}
                // ,{field: 'checkTime', sort: true, title: '盘验时间'}
                // ,{field: 'checkUserId', sort: true, title: '盘验人id'}
                // ,{field: 'checkUserName', sort: true, title: '盘验人'}
                // ,{field: 'notifyTime', sort: true, title: '通知时间'}
                // ,{field: 'notifyUserId', sort: true, title: '通知人'}
                // ,{field: 'notifyUserName', sort: true, title: '通知人'}
                // ,{field: 'takeUserId', sort: true, title: '回收人id'}
                // ,{field: 'takeUserName', sort: true, title: '回收人'}
                // ,{field: 'takeTime', sort: true, title: '回收时间'}
                // ,{field: 'inoutId', sort: true, title: '暂存柜存刀id'}
                // ,{field: 'cabId', sort: true, title: '柜子id'}
                // ,{field: 'skuId', sort: true, title: 'sku id'}
                // ,{field: 'companyId', sort: true, title: '企业id'}
                // ,{field: 'spaceId', sort: true, title: '货道id'}
                // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                // ,{field: 'quantityCurrent', sort: true, title: '当前库存'}
                // ,{field: 'quantityAfter', sort: true, title: '变动后库存'}

                ,{align: 'center', toolbar: '#storageCheckRepairResultOrderTableTableBar', title: '操作', width: 200}
            ]],
            done: function (res, curr, count) {

                //移除按钮

                var menuButton = config.getMenuButton(location.hash);
                if(menuButton.indexOf("搜索") == -1){
                    $('.layui-form.toolbar').remove();
                }
                if(menuButton.indexOf("修改") == -1){
                    $("[lay-event='edit']").remove();
                }
                if(menuButton.indexOf("删除") == -1){
                    $("[lay-event='del']").remove();
                }
            }
        });

        // 工具条点击事件
        table.on('tool(storageCheckRepairResultOrderTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') { //修改
                showEditModel(data);
            } else if (obj.event === 'del') { // 删除
                doDelete(obj);
            }else if(obj.event=='detail'){
                showDetailResultModel(data);
            }
        });

        //监听排序
        table.on('sort(storageCheckRepairResultOrderTable)', function(obj){
            table.reload('storageCheckRepairResultOrderTable', {
                initSort: obj
                ,where: {
                    sort: obj.field
                    ,order: obj.type
                }
            });
        });

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            insTb.reload({where: data.field,page: {curr: 1}},'data');
        });


        // 添加按钮点击事件
        $('#storageInventoryInoutBtnAdd').click(function () {
            showEditModel();
        });








        function getResultOrderTable(data){
            var insTb = table.render({
                elem: '#resultOrderTable',
                url: config.base + 'enterprisecab/cabinet/admin/checkedRepairResultOrder/list?id='+data.id,
                page: false,
                cellMinWidth: 100,
                cols: [[
                    {type: 'checkbox'}

                    ,{field: 'code', sort: true, title: '报修订单编号'}
                    // ,{field: 'inType', sort: true, title: '存入方式',templet:function (d) {
                    //         return '报废';
                    //     }}
                    ,{field: 'supplierName', sort: true, title: '供应商'}
                    ,{field: 'logisticsContact', sort: true, title: '物流联系人'}
                    ,{field: 'receiveContact', sort: true, title: '收货人'}
                    ,{field: 'phone', sort: true, title: '收货人电话'}
                    ,{field: 'addr', sort: true, title: '收货地址'}
                    ,{field: 'quantity', sort: true, title: '报修数量'}
                    ,{field: 'price', sort: true, title: '报修费用'}
                    ,{field: 'statusDesc', sort: true, title: '回收状态'}
                    ,{field: 'creatorName', sort: true, title: '创建人'}
                    ,{field: 'createTime', sort: true, title: '创建时间'}
                    // ,{field: 'isCheck', sort: true, title: '是否盘验',templet:function (d) {
                    //         if(d.status=='checked'){
                    //             return '是';
                    //         }
                    //         return  '否';
                    //     }}



                    // ,{field: 'no', sort: true, title: 'no'}
                    // ,{field: 'day', sort: true, title: 'day'}
                    // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                    // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                    // ,{field: 'statusDesc', sort: true, title: '状态'}
                    // ,{field: 'checkTime', sort: true, title: '盘验时间'}
                    // ,{field: 'checkUserId', sort: true, title: '盘验人id'}
                    // ,{field: 'checkUserName', sort: true, title: '盘验人'}
                    // ,{field: 'notifyTime', sort: true, title: '通知时间'}
                    // ,{field: 'notifyUserId', sort: true, title: '通知人'}
                    // ,{field: 'notifyUserName', sort: true, title: '通知人'}
                    // ,{field: 'takeUserId', sort: true, title: '回收人id'}
                    // ,{field: 'takeUserName', sort: true, title: '回收人'}
                    // ,{field: 'takeTime', sort: true, title: '回收时间'}
                    // ,{field: 'inoutId', sort: true, title: '暂存柜存刀id'}
                    // ,{field: 'cabId', sort: true, title: '柜子id'}
                    // ,{field: 'skuId', sort: true, title: 'sku id'}
                    // ,{field: 'companyId', sort: true, title: '企业id'}
                    // ,{field: 'spaceId', sort: true, title: '货道id'}
                    // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                    // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                    // ,{field: 'quantityCurrent', sort: true, title: '当前库存'}
                    // ,{field: 'quantityAfter', sort: true, title: '变动后库存'}

                    // ,{align: 'center', toolbar: '#storageCheckRepairResultOrderTableTableBar', title: '操作', width: 200}
                ]],
                done: function (res, curr, count) {

                    //移除按钮


                }
            });
        }

        function getDetailResultTable(data){
            var insTb = table.render({
                elem: '#detailResultTable',
                url: config.base + 'enterprisecab/cabinet/admin/checkedResult/list?resultOrderId='+data.id,
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {type: 'checkbox'}

                    ,{field: 'code', sort: true, title: '盘验编号'}
                    // ,{field: 'inType', sort: true, title: '存入方式',templet:function (d) {
                    //         return '报废';
                    //     }}
                    ,{field: 'cabCode', sort: true, title: '柜子编号'}
                    ,{field: 'spaceCode', sort: true, title: '货位编号'}
                    ,{field: 'skuName', sort: true, title: '物料名称'}
                    ,{field: 'skuCode', sort: true, title: '物料编号'}
                    ,{field: 'quantity', sort: true, title: '数量'}
                    ,{field: 'businessType', sort: true, title: '存储性质',templet:function (d) {
                            if(d.businessType=='temp'){
                                return '暂存';
                            }else if(d.businessType=='repair'){
                                return '报修'
                            }else if(d.businessType=='recycle'){
                                return '报废'
                            }
                        }}
                    ,{field: 'creatorName', sort: true, title: '责任人'}
                    ,{field: 'createTime', sort: true, title: '存入时间'}
                    // ,{field: 'isCheck', sort: true, title: '是否盘验',templet:function (d) {
                    //         if(d.status=='checked'){
                    //             return '是';
                    //         }
                    //         return  '否';
                    //     }}

                    ,{field: 'status', sort: true, title: '盘验状态',templet:function (d) {
                            if(d.status=='created'){
                                return '待盘验'
                            }
                            return  '已盘验'
                        }}
                    // ,{field: 'isGenOrder', sort: true, title: '是否已生成订单',templet:function (d) {
                    //         if(d.isGenOrder){
                    //             return '是'
                    //         }
                    //         return '否';
                    //     }}
                    // ,{field: 'no', sort: true, title: 'no'}
                    // ,{field: 'day', sort: true, title: 'day'}
                    // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                    // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                    // ,{field: 'statusDesc', sort: true, title: '状态'}
                    // ,{field: 'checkTime', sort: true, title: '盘验时间'}
                    // ,{field: 'checkUserId', sort: true, title: '盘验人id'}
                    // ,{field: 'checkUserName', sort: true, title: '盘验人'}
                    // ,{field: 'notifyTime', sort: true, title: '通知时间'}
                    // ,{field: 'notifyUserId', sort: true, title: '通知人'}
                    // ,{field: 'notifyUserName', sort: true, title: '通知人'}
                    // ,{field: 'takeUserId', sort: true, title: '回收人id'}
                    // ,{field: 'takeUserName', sort: true, title: '回收人'}
                    // ,{field: 'takeTime', sort: true, title: '回收时间'}
                    // ,{field: 'inoutId', sort: true, title: '暂存柜存刀id'}
                    // ,{field: 'cabId', sort: true, title: '柜子id'}
                    // ,{field: 'skuId', sort: true, title: 'sku id'}
                    // ,{field: 'companyId', sort: true, title: '企业id'}
                    // ,{field: 'spaceId', sort: true, title: '货道id'}
                    // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                    // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                    // ,{field: 'quantityCurrent', sort: true, title: '当前库存'}
                    // ,{field: 'quantityAfter', sort: true, title: '变动后库存'}

                    ,{align: 'center', toolbar: '#storageInventoryInoutTable4RepairOrderBar', title: '操作', width: 200}
                ]],
                done: function (res, curr, count) {

                    //移除按钮

                    var menuButton = config.getMenuButton(location.hash);
                    if(menuButton.indexOf("搜索") == -1){
                        $('.layui-form.toolbar').remove();
                    }
                    if(menuButton.indexOf("修改") == -1){
                        $("[lay-event='edit']").remove();
                    }
                    if(menuButton.indexOf("删除") == -1){
                        $("[lay-event='del']").remove();
                    }
                }
            });

            // 工具条点击事件
            table.on('tool(detailResultTable)', function (obj) {
                var data = obj.data;
                if (obj.event === 'edit') { //修改
                    showEditModel(data);
                } else if (obj.event === 'del') { // 删除
                    doDelete(obj);
                }else if(obj.event=='detail'){
                    showDetailModel(data);
                }
            });

            //监听排序
            table.on('sort(detailResultTable)', function(obj){
                table.reload('detailResultTable', {
                    initSort: obj
                    ,where: {
                        sort: obj.field
                        ,order: obj.type
                    }
                });
            });
        }

        function showDetailResultModel(data){

            admin.open({
                type: 1,
                area: '1480px',
                offset: '65px',
                title: '详情',
                content: $('#detailResultTab').html(),
                success: function () {
                    getResultOrderTable(data)
                    getDetailResultTable(data);

                }
            })

        }

        function showDetailModel(data){
            admin.open({
                type: 1,
                area: '1480px',
                offset: '65px',
                title: '详情',
                content: $('#detailTable').html(),
                success: function () {
                    var insTb = table.render({
                        elem: '#storageInventoryInoutTable4RepairOrder',
                        url: config.base + 'enterprisecab/cabinet/admin/storageInventoryInout/list?checkResultId='+data.id,
                        page: true,
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'numbers'}

                            ,{field: 'code', sort: true, title: '盘验任务编号'}
                            // ,{field: 'inType', sort: true, title: '存入方式',templet:function (d) {
                            //         return '报废';
                            //     }}
                            ,{field: 'cabCode', sort: true, title: '柜子编号'}
                            ,{field: 'spaceCode', sort: true, title: '货位编号'}
                            ,{field: 'skuName', sort: true, title: '物料名称'}
                            ,{field: 'skuCode', sort: true, title: '物料编号'}
                            ,{field: 'quantity', sort: true, title: '数量'}
                            ,{field: 'businessType', sort: true, title: '存储性质',templet:function (d) {
                                    if(d.businessType=='temp'){
                                        return '暂存';
                                    }else if(d.businessType=='repair'){
                                        return '报修'
                                    }else if(d.businessType=='recycle'){
                                        return '报废'
                                    }
                                }}
                            ,{field: 'creatorName', sort: true, title: '责任人'}
                            ,{field: 'createTime', sort: true, title: '存入时间'}
                            // ,{field: 'isCheck', sort: true, title: '是否盘验',templet:function (d) {
                            //         if(d.status=='checked'){
                            //             return '是';
                            //         }
                            //         return  '否';
                            //     }}

                            ,{field: 'status', sort: true, title: '盘验状态',templet:function (d) {
                                    if(d.status=='created'){
                                        return '待盘验'
                                    }
                                    return  '已盘验'
                                }}
                            // ,{field: 'no', sort: true, title: 'no'}
                            // ,{field: 'day', sort: true, title: 'day'}
                            // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                            // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                            // ,{field: 'statusDesc', sort: true, title: '状态'}
                            // ,{field: 'checkTime', sort: true, title: '盘验时间'}
                            // ,{field: 'checkUserId', sort: true, title: '盘验人id'}
                            // ,{field: 'checkUserName', sort: true, title: '盘验人'}
                            // ,{field: 'notifyTime', sort: true, title: '通知时间'}
                            // ,{field: 'notifyUserId', sort: true, title: '通知人'}
                            // ,{field: 'notifyUserName', sort: true, title: '通知人'}
                            // ,{field: 'takeUserId', sort: true, title: '回收人id'}
                            // ,{field: 'takeUserName', sort: true, title: '回收人'}
                            // ,{field: 'takeTime', sort: true, title: '回收时间'}
                            // ,{field: 'inoutId', sort: true, title: '暂存柜存刀id'}
                            // ,{field: 'cabId', sort: true, title: '柜子id'}
                            // ,{field: 'skuId', sort: true, title: 'sku id'}
                            // ,{field: 'companyId', sort: true, title: '企业id'}
                            // ,{field: 'spaceId', sort: true, title: '货道id'}
                            // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                            // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                            // ,{field: 'quantityCurrent', sort: true, title: '当前库存'}
                            // ,{field: 'quantityAfter', sort: true, title: '变动后库存'}

                            ,{align: 'center', toolbar: '#storageInventoryInoutTable4RepairOrderBar', title: '操作', width: 200}
                        ]],
                        done: function (res, curr, count) {
                            //移除按钮
                            var menuButton = config.getMenuButton(location.hash);
                            if(menuButton.indexOf("搜索") == -1){
                                $('.layui-form.toolbar').remove();
                            }
                            if(menuButton.indexOf("修改") == -1){
                                $("[lay-event='edit']").remove();
                            }
                            if(menuButton.indexOf("删除") == -1){
                                $("[lay-event='del']").remove();
                            }
                        }
                    });

                    // 工具条点击事件
                    table.on('tool(storageInventoryInoutTable4RepairOrder)', function (obj) {
                        var data = obj.data;
                        if (obj.event === 'edit') { //修改
                            showEditModel(data);
                        } else if (obj.event === 'del') { // 删除
                            doDelete(obj);
                        }else if(obj.event=='detail'){
                            admin.req('enterprisecab/cabinet/admin/storageInventoryInout/detail/' + obj.data.id, {}, function (res) {
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    showEditModel(res.data);
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, 'GET');
                        }
                    });

                    function showEditModel(data) {
                        admin.open({
                            type: 1,
                            area: '1280px',
                            offset: '65px',
                            title: '详情',
                            content: $('#storageInventoryInoutForm').html(),
                            success: function () {
                                if (data) {
                                    var option = $("form select[name='operationType']").find("option");
                                    layui.each(option, function (index, item) {
                                        if (data.operationType == item.text) {
                                            data.operationType = item.value;
                                        }
                                    });
                                }

                                if (data) {
                                    var option = $("form select[name='businessType']").find("option");
                                    layui.each(option, function (index, item) {
                                        if (data.businessType == item.text) {
                                            data.businessType = item.value;
                                        }
                                    });
                                }

                                if (data) {
                                    var option = $("form select[name='status']").find("option");
                                    layui.each(option, function (index, item) {
                                        if (data.status == item.text) {
                                            data.status = item.value;
                                        }
                                    });
                                }

                                $(".model-form input").css("border", "none")
                                $(".model-form input").attr('readonly', true);

                                var insTb = table.render({
                                    elem: '#storageInventoryInoutDetailTable',
                                    url: config.base + 'enterprisecab/cabinet/admin/storageInventoryInoutDetail/list?inoutId=' + data.id,
                                    page: true,
                                    cellMinWidth: 100,
                                    cols: [[
                                        {type: 'numbers'}

                                        , {field: 'spaceCode', sort: true, title: '所属货位'}
                                        , {
                                            field: 'skuPic', sort: true, title: '物料图片', templet: function (d) {
                                                if (d.skuPic) {
                                                    return '<img src="' + config.base + 'file/admin/file/get/' + d.skuPic + '" style="height: 20px;"/>';
                                                }
                                                return '';
                                            }
                                        }
                                        , {field: 'skuCode', sort: true, title: '物料编号'}
                                        , {field: 'skuName', sort: true, title: '物料名称'}
                                        , {field: 'skuSpec', sort: true, title: '规格'}
                                        , {field: 'productBrandName', sort: true, title: '品牌'}
                                        , {field: 'quantity', sort: true, title: '数量'}
                                        , {field: 'checkCode', sort: true, title: '盘验编号'}
                                        , {field: 'checkTime', sort: true, title: '盘验时间'}

                                    ]],
                                    done: function (res, curr, count) {
                                        //移除按钮
                                        var menuButton = config.getMenuButton(location.hash);
                                        if (menuButton.indexOf("搜索") == -1) {
                                            $('.layui-form.toolbar').remove();
                                        }
                                        if (menuButton.indexOf("修改") == -1) {
                                            $("[lay-event='edit']").remove();
                                        }
                                        if (menuButton.indexOf("删除") == -1) {
                                            $("[lay-event='del']").remove();
                                        }
                                    }
                                });

                                form.val('storageInventoryInoutForm', data);
                                // 表单提交事件

                            }
                        });
                    }

                    //监听排序
                    table.on('sort(storageInventoryInoutTable4RepairOrder)', function(obj){
                        table.reload('storageInventoryInoutTable4RepairOrder', {
                            initSort: obj
                            ,where: {
                                sort: obj.field
                                ,order: obj.type
                            }
                        });
                    });

                    // 搜索
                    form.on('submit(formSubSearchLog)', function (data) {
                        insTb.reload({where: data.field,page: {curr: 1}},'data');
                    });
                }
            })
        }

        // 显示编辑弹窗
        function showEditModel(data) {
            admin.open({
                type: 1,
                area: '880px',
                offset: '65px',
                title: data ? '修改暂存柜存刀/取刀;存/取报修/回收刀' : '添加暂存柜存刀/取刀;存/取报修/回收刀',
                content: $('#storageInventoryInoutForm').html(),
                success: function () {
                    if (data){
                        var option = $("form select[name='operationType']").find("option");
                        layui.each(option, function(index, item){
                            if(data.operationType  == item.text){
                                data.operationType = item.value;
                            }
                        });
                    }

                    if (data){
                        var option = $("form select[name='businessType']").find("option");
                        layui.each(option, function(index, item){
                            if(data.businessType  == item.text){
                                data.businessType = item.value;
                            }
                        });
                    }

                    if (data){
                        var option = $("form select[name='status']").find("option");
                        layui.each(option, function(index, item){
                            if(data.status  == item.text){
                                data.status = item.value;
                            }
                        });
                    }

                    form.val('storageInventoryInoutForm', data);
                    // 表单提交事件
                    form.on('submit(storageInventoryInoutFormSubmit)', function (d) {
                        layer.load(2);
                        admin.req(data ? 'enterprisecab/cabinet/admin/storageInventoryInout/update' : 'enterprisecab/cabinet/admin/storageInventoryInout/add', d.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('storageInventoryInoutTable4RepairOrder');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, data ? 'PUT' : 'POST');
                        return false;
                    });
                }
            });
        }

        // 删除
        function doDelete(obj) {
            layer.confirm('确定要删除吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprisecab/cabinet/admin/storageInventoryInout/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
            });
        }

        // 导出excel
        $('#storageInventoryInoutBtnExport').click(function () {
            var checkRows = table.checkStatus('storageInventoryInoutTable4RepairOrder');
            if (checkRows.data.length == 0) {
                layer.msg('请选择要导出的数据', {icon: 2});
            } else {
                table.exportFile(insTb.config.id, checkRows.data, 'xls');
            }
        });

    });
</script>